#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    vector<int> sortArrayByParityII(vector<int>& nums)
    {
        int i = 0, j = 1;
        while (i < nums.size())
        {
            if (nums[i] % 2 == 1)
            {
                while (nums[j] % 2 == 1)
                {
                    j += 2;
                }
                swap(nums[i], nums[j]);
            }
            i += 2;
        }
        return nums;
    }
};